var app = getApp()
var axios = require("../../utils/core")
Page({

    /**
     * 页面的初始数据
     */
    data: {
        list: [],
        listt: [], //已开会员卡
        userinfo: null,
        page: 1,
        cate: "my", //已开会员卡
        member: {},
        cards: {} //全部可开会员卡
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        var that = this
        axios.post("goods.xfhy", {}, ((e) => {
            that.setData({
                list: e
            })
        }))
        //获取全部可开会员卡
        axios.get("membercard.getlist", {
            page: that.data.page,
            cate: "all"
        }, ((e) => {
            that.setData({
                cards: e.list
            })
        }))
        axios.get("membercard.getlist", {
            page: that.data.page,
            cate: that.data.cate
        }, ((e) => {
            that.setData({
                listt: e.list
            })
        }))
        var userinfo = wx.getStorageSync('userinfo')
        that.setData({
            userinfo: userinfo
        })
        axios.get("member", {}, ((e) => {
            console.log(e);
            that.setData({
                member: e
            })
        }))
    },
    Open(e) {
        axios.post("membercard.order.create_order", {
            id: e.currentTarget.dataset.id
        }, ((el) => {
            wx.navigateTo({
                url: "/pages/member/membercard/pay/index?order_id=" + el.order.order_id
            })
        }))
    },



    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})